package cn.tutou.tw.ck.jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Set;

public class AppjdbcSelect {
    public static void main(String[] args) throws Exception {
        //加载驱动
        Class.forName("com.mysql.jdbc.Driver");
        //获取链接
        String url = "jdbc:mysql://localhost:3306/test?useSSl=false";
        String username = "root";
        String password = "root";
        Connection connection = DriverManager.getConnection(url, username, password);
        //创建陈述对象
        Statement statement = connection.createStatement();
        //执行查询
        String sql= "SELECT `id`,`username`,`password` FROM `test1` ORDER BY id";
        ResultSet set = statement.executeQuery(sql);
        //获取数据
        set.next();
        set.getString(2);
        boolean next = set.next();
        System.out.println(next);
        while (set.next()){
            String v = set.getString(2);
            Long id = set.getLong(1);
            System.out.println("ID is : "+id+"  username is : " + v);
        }
        // set.getString(2);
        // System.out.println(set.getString(2));



    }
}
